package com.hdu.hot100.doublePointer;

public class lc11 {
    class Solution {
        public int maxArea(int[] height) {
            int left = 0;
            int right = height.length - 1;
            int ans = Integer.MIN_VALUE;
            while (left < right)
            {
                int leftHeight = height[left];
                int rightHeight = height[right];
                int bottomHeight = Math.min(leftHeight, rightHeight);
                ans = Math.max(ans, (right - left) * bottomHeight);
                if (leftHeight == bottomHeight) left++;
                else right--;
            }
            return ans;
        }
    }
}
